home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / BACKUP / NEWDISK.ZIP;1 / NEWDISK.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-11-19  |  6.0 KB  |  148 lines

  1. ;       Program author:  Jeffrey S. Coy Jr.     11/18/93
  2. ;
  3. ;
  4. ;       This program was written to facilitate an error on a friend's computer.
  5. ;
  6. ;       The computer was incapable of recognizing when a new disk was inserted
  7. ;       into a drive, and caused failure on most multi-disk program
  8. ;       installations.
  9. ;
  10. ;       The simplest solution was to run DOS's CHKDSK.EXE to force the computer
  11. ;       to recognize the new disk, but this was impossible to do from within
  12. ;       another .exe program (such as install.exe).  A second solution was to
  13. ;       run desqview and open a second window during installation to run the
  14. ;       chkdsk.exe program, but this was an inconvinience at best.
  15. ;
  16. ;       This program patches into the keyboard flag's so that whenever they are
  17. ;       invoked this program will search for RIGHT SHIFT-SCROLL LOCK.  If this
  18. ;       combination is triggered, this program will go to 40h:3f7h and set
  19. ;       bit 7 (diskette change bit) on the floppy drive controller.
  20. ;       Nothing is output to screen, as this would be annoying.
  21. ;
  22. ;       Let it be known that more time was spent on these brief notes than on
  23. ;       the acctual program.
  24. ;
  25. ;       LEGAL STUFF:  all mentioned programs, companies, &c are copyright of
  26. ;       same/said.  This program is dedicated to the public domain and free
  27. ;       distribution is highly encouraged.  May others follow this same
  28. ;       ideology (please).  If you feel you must send me money, you have to
  29. ;       find me first (GRIN).
  30. ;
  31. ;       PS:     I hope this works.
  32. ;
  33. ;To assemble: MASM NEWDISK
  34. ;             LINK NEWDISK
  35. ;             EXE2BIN NEWDISK.EXE NEWDISK.COM
  36. ;             DEL NEWDISK.EXE
  37. ;
  38. cr      equ     10
  39. lf      equ     13
  40. space   equ     32
  41.  
  42. rightshift      equ     00000001b ;at 40h:17h this is flag for right shift depressed
  43. leftshift       equ     00000010b ;at 40h:17h this is flag for left shift depressed
  44. scrollock       equ     00010000b ;at 40h:18h this is flag for scroll lock depressed
  45. diskchange      equ     10000000b ;at 40h:3f7h this is flag for disk change
  46.  
  47. DUMMY   SEGMENT STACK                              ;Avoid linking error
  48. DUMMY   ENDS                                       ;All segments must end
  49. CODE    SEGMENT
  50.         ASSUME CS:CODE, DS:CODE, ES:CODE, SS:CODE  ;COM type program
  51.         ORG 100H                                   ;starts at 100h
  52.                                                    ;all segments common
  53.  
  54. START:  JMP  SETUP
  55.  
  56.         ;This is our interrupt service routine.  It will be executed each time
  57.         ;the bios keyboard interrupt is triggered.
  58.  
  59.         DB   3
  60. TRAP:
  61.         sti
  62.         pushf
  63.         PUSH AX                         ;save a bunch of registers
  64.         PUSH BX
  65.         PUSH CX
  66.         PUSH DX
  67.         PUSH DS
  68.         PUSH ES
  69.         PUSH BP
  70.         push si
  71.         push di
  72.         PUSH CS
  73.         POP  DS                         ;get CS to DS
  74. checkright:
  75.         MOV  BX,40H                     ;get BIOS data segment          }
  76.         MOV  ES,BX                      ;to ES                          }  / This is much more compact \
  77.         MOV  BX,17H                     ;use BX to form full pointer    }-<  and thus much faster than  >
  78.         MOV  AL,BYTE PTR ES:[BX]        ;look at keyboard flags         }  \ INT 16H function 2.       /
  79.         and     al,rightshift           ;is rightshift depressed?
  80.         jnz     chkscroll               ;if so go check the scroll lock
  81.         jmp     SKIP                    ;else SKIP out
  82. chkscroll:
  83.         MOV  BX,40H                     ;get BIOS data segment          }
  84.         MOV  ES,BX                      ;to ES                          }  / This is much more compact \
  85.         MOV  BX,18H                     ;use BX to form full pointer    }-<  and thus much faster than  >
  86.         MOV  AL,BYTE PTR ES:[BX]        ;look at keyboard flags         }  \ INT 16H function 2.       /
  87.         and     al,scrollock            ;is scroll lock depressed?
  88.         jnz     settheflag              ;if so, go set the flag
  89.         jmp     SKIP                    ;else SKIP out
  90. settheflag:
  91.         mov     bx,40h                  ;get bios data segment to es
  92.         mov     es,bx
  93.         mov     bx,3f7h                 ;configuration control register
  94.         mov     al,byte ptr ES:[BX]     ;get current status of controller
  95.         or      al,diskchange           ;set disk change bit
  96.         mov     byte ptr ES:[BX],al     ;and put flags back
  97. SKIP:
  98.         pop  di                         ;restore all registers
  99.         pop  si
  100.         POP  BP
  101.         POP  ES
  102.         POP  DS
  103.         POP  DX
  104.         POP  CX
  105.         POP  BX
  106.         POP  AX
  107.         popf
  108.         JMP  DWORD PTR CS:VECSAV           ;chain to original vector owner
  109. VECSAV:         DD      0
  110.                 db      0
  111.  
  112. END_RES LABEL   NEAR        ;Mark end of resident code
  113.  
  114.         ;First we set up our interrupt vector so we can use it
  115.  
  116. SETUP:
  117.         PUSH    CS
  118.         POP     DS
  119.         MOV     AX,3509H                     ;keyboard hardware interrupt
  120.         INT     21H
  121.         MOV     WORD PTR VECSAV,BX
  122.         MOV     WORD PTR VECSAV[2],ES
  123.         MOV     AL,BYTE PTR ES:[BX[-1]]      ;See what vector points to
  124.         CMP     AL,03H                       ;skel.COM already loaded?
  125.         JZ      ABORT                        ;if so, exit.
  126.         PUSH    CS
  127.         POP     DS
  128.         MOV     AX,2509H
  129.         MOV     DX,OFFSET TRAP
  130.         INT     21H
  131.         MOV     AH,09
  132.         MOV     DX,OFFSET SIGNON
  133.         INT     21H
  134.         MOV     DX,OFFSET END_RES       ;Mark end of resident code
  135.         INT     27H                     ;Terminate and stay resident
  136. ABORT:  MOV     DX,OFFSET SIGNOF
  137.         MOV     AH,09
  138.         INT     21H
  139.         INT     20H
  140.  
  141. SIGNON: DB      CR,LF,'NEWDISK.COM LOADED',CR,LF,CR,LF,'$'
  142. SIGNOF: DB      CR,LF,'NEWDISK.COM already loaded',CR,LF,CR,LF,'$'
  143.  
  144.  
  145. CODE    ENDS                ;Mark end of our Code segment
  146.         END START           ;Tell Assembler where to begin execution
  147.  
  148.